window.onload   = resize;
window.onresize = resize;

function resize() {
    var bh = document.body.offsetHeight,
        mh = document.getElementById('main').offsetHeight;

    document.getElementById('sidebar').style.height = Math.max(bh, mh) + 'px';
}